﻿using System.Collections.Concurrent;

namespace qYun.ApiService.Services;

/// <summary>
/// 共有静态变量
/// </summary>
public class SharedStateService
{
    private readonly ConcurrentDictionary<string, object> _sharedData = new();

    /// <summary>
    /// 设置共有值
    /// </summary>
    /// <param name="key"></param>
    /// <param name="value"></param>
    public void SetValue(string key, object value)
    {
        _sharedData[key] = value;
    }
    /// <summary>
    /// 获取共有值
    /// </summary>
    /// <param name="key"></param>
    /// <returns></returns>
    public object? GetValue(string key)
    {
        return _sharedData.GetValueOrDefault(key);
    }
}